load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "handle",
    srcs = [
        "bootstrap.go",
        "ddl.go",
        "dump.go",
        "gc.go",
        "handle.go",
        "handle_hist.go",
        "historical_stats_handler.go",
        "lock_stats_handler.go",
        "update.go",
    ],
    importpath = "github.com/pingcap/tidb/statistics/handle",
    visibility = ["//visibility:public"],
    deps = [
        "//config",
        "//ddl/util",
        "//infoschema",
        "//kv",
        "//metrics",
        "//parser/ast",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//sessiontxn",
        "//statistics",
        "//statistics/handle/cache",
        "//statistics/handle/lockstats",
        "//statistics/handle/metrics",
        "//table",
        "//types",
        "//util",
        "//util/chunk",
        "//util/logutil",
        "//util/mathutil",
        "//util/sqlexec",
        "//util/syncutil",
        "//util/timeutil",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_tiancaiamao_gp//:gp",
        "@com_github_tikv_client_go_v2//oracle",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "handle_test",
    timeout = "short",
    srcs = [
        "ddl_test.go",
        "dump_test.go",
        "gc_test.go",
        "handle_hist_test.go",
        "main_test.go",
        "update_list_test.go",
    ],
    embed = [":handle"],
    flaky = True,
    race = "on",
    shard_count = 26,
    deps = [
        "//config",
        "//domain",
        "//parser/model",
        "//planner/cardinality",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//statistics",
        "//statistics/handle/internal",
        "//testkit",
        "//testkit/testsetup",
        "//types",
        "//util",
        "//util/mathutil",
        "//util/mock",
        "//util/sqlexec",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
